<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:f="http://java.sun.com/jsf/core"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui" >
<f:metadata>
	<f:viewParam name="id" value="#{pwserviceBean.id}" />
</f:metadata>
<ui:composition template="/WEB-INF/template/basic-template.xhtml">
	<ui:define name="title"><h:outputText value="Gestione Servizio Spider"/></ui:define>
	<ui:define  name="content">
		<f:view>
			<h:form id="crudForm">
				<p:panel id="crudPanel">
					<f:facet name="header">
						<span class="headerTitle"><h:outputText value="Gestione Servizio Spider"/></span>
					</f:facet>
					
					<p:panel id="attributi" header="Attributi" toggleable="true">
						<p:panelGrid>
							<p:row>
								<p:column>Code</p:column>
								<p:column>
									<p:inputText label="Code"
										value="${pwserviceBean.service.code}"
										maxlength="20"
										required="true"
										size="20" >
									</p:inputText>
								</p:column>
							</p:row>
							<p:row>
								<p:column>Label</p:column>
								<p:column>
									<p:inputText label="Label"
										value="${pwserviceBean.service.label}"
										maxlength="50"
										required="true"
										size="50" >
									</p:inputText>
								</p:column>
							</p:row>
							<p:row>
								<p:column>Description</p:column>
								<p:column>
									<p:inputText label="Description"
										value="${pwserviceBean.service.description}"
										maxlength="255"
										required="false"
										size="100" >
									</p:inputText>
								</p:column>
							</p:row>
						</p:panelGrid>
					</p:panel>

					<p:panel id="serviceInputParams" header="Input Params" toggleable="true">
						<span class="headerButton">
							<p:commandButton styleClass="pulsante-icon"  
											 actionListener="#{pwserviceBean.doNewServiceInputParam}"
											 icon="ui-icon-aggiungi" 
											 title="Aggiungi Parametro Input"
											 update=":crudForm:serviceInputParams,:messages">
								<p:resetInput target=":crudForm"></p:resetInput>
							</p:commandButton>
						</span>
						<h:dataTable var="p" 
	  							 id="serviceInputParamTable" 
	  							 value="#{pwserviceBean.service.inputParams}" 
	  							 widgetVar="serviceInputParamsWidget"
								 styleClass="tabellaElenco"
								 rowKey="#{p}">
							<h:column>
								<p:commandButton styleClass="pulsante-icon"  
										 actionListener="#{pwserviceBean.doEditServiceInputParam}"
											 icon="ui-icon-edit" 
											 id="serviceInputParamButton"
											 title="Aggiorna Parametro"
											 oncomplete="crudFormDialogWidget.show();"
											 update=":dialogForm,:messages">
									<f:setPropertyActionListener for="serviceInputParamButton" 
											target="#{pwserviceBean.serviceInputParamId}" value="#{p.id}" />
								</p:commandButton>
							</h:column>
							<h:column>
								<h:outputText value="${p.name}"></h:outputText>
							</h:column>
							<h:column>
								<h:outputText value="${p.value}"></h:outputText>
							</h:column>
						</h:dataTable>
					</p:panel>
					
					<f:facet name="footer">
						<p:column colspan="2">
							<p:commandButton styleClass="pulsante-save"
								value="#{pwserviceBean.insertMode?'Inserisci':'Aggiorna'}"
								type="submit" actionListener="#{pwserviceBean.doSave}"
								oncomplete="handleSaveRequest(xhr, status, args)"
								update=":messages,:crudForm">
							</p:commandButton>
							<p:commandButton styleClass="pulsante-delete" 
									value="elimina" type="submit"
									rendered="#{! pwserviceBean.insertMode}"
									onclick="crudFormConfirmationWidget.show()">
							</p:commandButton>
						</p:column>

					</f:facet>
	     		</p:panel>

			</h:form>

			<h:form id="dialogForm">
				<p:dialog   id="crudFormDialog" 
							styleClass="dialogUpdate"
							header="Gestione Parametri"
							modal="true"  
							widgetVar="crudFormDialogWidget">
					<p:panel id="crudFormPanel">
						<p:panelGrid>
							<p:row>
								<p:column>Name</p:column>
								<p:column>
									<p:inputText label="name"
										value="${pwserviceBean.param.name}"
										maxlength="20"
										required="true"
										size="20" >
									</p:inputText>
								</p:column>
							</p:row>
							<p:row>
								<p:column>Value</p:column>
								<p:column>
									<p:inputText label="Value"
										value="${pwserviceBean.param.value}"
										maxlength="150"
										required="true"
										size="150" >
									</p:inputText>
								</p:column>
							</p:row>
						</p:panelGrid>
					</p:panel>
				</p:dialog>
			</h:form>



		</f:view>



	</ui:define>
</ui:composition>
</html>
